<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String gd_content_id = request.getParameter("gd_content_id") == null ? "" : request.getParameter("gd_content_id");
    String gd_id = request.getParameter("gd_id") == null ? "" : request.getParameter("gd_id");
%>
<html>
	<head>
		<link href="<%=contextPath%>/public/css/smart_wizard_vertical.css" rel="stylesheet"	type="text/css">
		<script type="text/javascript" src="<%=contextPath%>/public/js/jquery.smartWizard.js"></script>
		<link  rel="stylesheet"  href  ="<%=contextPath%>/public/swfupload/css/swfupload.css">
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
			}
			.tdg{
			padding-top:10px;
			padding-bottom:5px;
			font-size: 12px;
			background-color: #c0ebd7;
			width:20%;
		}
		.tdb{
			padding:5px;
			width:30%;
		}
		</style>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/datastructs.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/sys.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/core/js/prototype.js"  ></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/attachMenu.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/Menu.js"></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/fileprogress.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/handlers.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.queue.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/springViews/gd/gd.js"  ></script>
		<script type="text/javascript">
		var isShow = 1;
		var gd_content_id="<%=gd_content_id%>";
		function showCallback(obj,context){
			if(context.toStep == 2){//显示分包预算
				jQuery('#fb_detail').datagrid('acceptChanges');
				var data = jQuery('#fb_detail').datagrid('getData');
				jQuery('#fb_detail').datagrid('loadData',data);
			}
			if(context.toStep == 3){//显示材料预算
				jQuery('#material').datagrid('acceptChanges');
				var data = jQuery('#material').datagrid('getData');
				jQuery('#material').datagrid('loadData',data);
			}
		}
			jQuery(document).ready(function() {
				jQuery('#gdForm').form({
					onLoadSuccess:function(data){
							gd_content_id=data.gd_content_id;
						queueCompleteOver();
						//加载分包预算
						loadFB();
						//加载材料预算
						loadMaterial();
						//加载上传附件插件
						loadUpload();
						
						// Smart Wizard 	
						jQuery('#wizard').smartWizard( {
							transitionEffect : 'slide',
							keyNavigation:false,
							labelFinish:'关闭',
							labelNext:'下一步', // label for Next button
						    labelPrevious:'上一步', // label for Previous button
						    onShowStep:showCallback,
							onFinish:onFinishCallback
						});
					}
				});
				jQuery('#gdForm').form("load",'<%=contextPath %>/springMVC/gd/getGDBaseById?gd_id=<%=gd_id%>&gd_content_id=<%=gd_content_id%>');
				jQuery.ajax({
					type:"POST",
					async:false,
					url:"<%=contextPath %>/springMVC/gd/getGDControl?gd_id=<%=gd_id%>&gd_content_id="+gd_content_id,
					success:function(rtData){
						jQuery('#control').val(rtData);
					}
				});
			});

			function loadMaterial(){
					jQuery('#material').datagrid({
					  	title:'材料预算',
					  	iconCls:'icon-edit',
						url:'<%=contextPath%>/springMVC/gd/listPageMaterial?gd_id=<%=gd_id%>&gd_content_id='+gd_content_id,
					  	rownumbers:true,
					  	singleSelect:true,
						fitColumns:true,
						nowrap:false,
						showFooter:true,
						frozenColumns:[[
						    {title:'材料id',field:'material_id',hidden:true}
						]],
						columns:[[
							{title:'材料编号',field:'code',width:100,align:'center'},
							{title:'材料名称',field:'name',width:200,align:'center'},
							{title:'规格/型号',field:'format_type',width:200,align:'center'},
							{title:'单位',field:'unit_name',width:50,align:'center'},
							{title:'预算单价',field:'price',width:100,align:'center'},
							{title:'预算数量',field:'num',width:100,align:'center'},
							{title:'备注',field:'remark',width:260,align:'center'}
						]],
						pageSize:10,
						pageList : [10,50,100],  
						pagination:true,
						onLoadSuccess:function(data){
							showMFooter();
						}
					});
			}

			var swfupload;
			function loadUpload(){
				var settings = {
					      flash_url : "<%=contextPath%>/public/swfupload/swfupload.swf",
					      upload_url: "<%=contextPath%>/springMVC/fileUpload/fileupload",
					      post_params: {
					    	 "module" : "<%=com.beaut.project.util.StaticData.GD_MODULE%>"
					      },
					      file_size_limit : "100 MB",
					      file_types : "*.*",
					      file_types_description : "All Files",
					      file_upload_limit : 100,
					      file_queue_limit : 0,
					      custom_settings : {
					        uploadArea : "fsUploadArea",
					        progressTarget : "fsUploadProgress",
					        startButtonId : "btnStart",
					        cancelButtonId : "btnCancel"
					      },
					      debug: false,
					      button_image_url: "<%=contextPath%>/public/swfupload/img/uploadx4.gif",
					      button_width: "65",
					      button_height: "29",
					      button_placeholder_id: "spanButtonUpload",
					      button_text: '<span class=\"textUpload\">上传附件</span>',
					      button_text_style: ".textUpload{color:#0000ff;}",
					      button_text_top_padding : 1,
					      button_text_left_padding : 18,
					      button_width: 80,
					      button_height: 20,
					      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
					      button_cursor: SWFUpload.CURSOR.HAND,
					      
					      file_queued_handler : fileQueued,
					      file_queue_error_handler : fileQueueError,
					      file_dialog_complete_handler : fileDialogComplete,
					      upload_start_handler : uploadStart,
					      upload_progress_handler : uploadProgress,
					      upload_error_handler : uploadError,
					      upload_success_handler : uploadSuccessOver,
					      upload_complete_handler : uploadComplete,
					      queue_complete_handler : queueCompleteOver
					    };
					    swfupload = new SWFUpload(settings);
			}

			function loadFB(){
				jQuery('#fb_detail').datagrid({
				  	title:'分包预算',
				  	iconCls:'icon-edit',
				  	url:'<%=contextPath%>/springMVC/gd/listPageFBDetail?gd_id=<%=gd_id%>&gd_content_id='+gd_content_id,
				  	rownumbers:true,
				  	singleSelect:true,
				  	nowrap:false,
					fitColumns:true,
					showFooter:true,
					frozenColumns:[[
					    {title:'分包结算id',field:'id',hidden:true},
					    {title:'分包栏目id',field:'fb_item_id',hidden:true}
					]],
					columns:[[
						{title:'栏目名称',field:'fb_item_name',width:50,align:'center'},
						{title:'预算成本',field:'budget',width:50,align:'center'},
						{title:'预算备注',field:'budget_remark',width:100,align:'center'}
					]],
					onLoadSuccess:function(data){
						showFFooter();
					},
					pageSize:10,
					pageList : [10,50,100],  
					pagination:true
				});
			}	
			function onFinishCallback() {
					window.close();
			}
			function gdPrint(){
				var  tempReturnValue= window.open("<%=contextPath%>/springViews/print/startGdPrint.jsp?gd_id=<%=gd_id%>&gd_content_id="+gd_content_id ,window,'height=1000, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
			}
		</script>
	</head>
	<body>
		<div >
		<table align="center" border="0" cellpadding="0" cellspacing="0" style="height: 100%;width:100%">
			<tr>
				<td>
					<!-- Smart Wizard -->
					<div id="wizard" class="swMain">
						<ul>
							<li>
								<a href="#step-1"> <label class="stepNumber">
										1
									</label> <span class="stepDesc"> 派工单<br /> <small></small> </span> </a>
							</li>
							<li>
								<a href="#step-2"> <label class="stepNumber">
										2
									</label> <span class="stepDesc"> 分包预算<br /> <small></small> </span> </a>
							</li>
							<li>
								<a href="#step-3"> <label class="stepNumber">
										3
									</label> <span class="stepDesc"> 材料预算<br /> <small></small> </span> </a>
							</li>
						</ul>
						<div id="step-1" style="width:700px;height:550px">
							<form id="gdForm">
							<table  style="border-collapse: collapse;" border="1px" bordercolor="#0eb83a" >
								<tr>
									 <td align="right" nowrap class="td1">
										客户：
									</td>
									<td class="td2" nowrap>
										<input id="customer" name="customer" >
									</td>
									<td align="right" nowrap class="td1">
										工单依据：
									</td>
									<td class="td2" nowrap >
										<input id="gd_depand_name"  name="gd_depand_name" /> 
									</td>
								</tr>
								<tr style="display:none;">
									 <td align="right" nowrap class="td1">
										项目名称：
									</td>
									<td class="td2" nowrap>
										<input type="hidden" id="xm_id" name="xm_id"  >
										<input type="text" id="xm_name" name="xm_name"  onclick="choseXm();">
										<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:false" onclick="choseXm();"></a>
									</td>
								  <td align="right" nowrap class="td1">
										项目编号：
									</td>
									<td class="td2" nowrap>
										
										<input type="text" id="xm_code" name="xm_code" >
									</td>
								</tr>
								<tr>
									 <td align="right" nowrap class="td1">
										工单名称：
									</td>
									<td class="td2" nowrap>
										<input type="text" id="gd_name" name="gd_name"  >
									</td>
								  <td align="right" nowrap class="td1">
										工单编号：
									</td>
									<td class="td2" nowrap>
										<input type="text" id="gd_code" name="gd_code"  >
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										派单人：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="gd_admin_name" name="gd_admin_name" >
									</td>
									<td align="right"  nowrap class="td1">
										所属部门：
									</td>
									<td class="td2" nowrap >
										<input type="hidden" id="dept_id" name="dept_id">
										<input type="text" id="dept_name" name="dept_name" >
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										发包人：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="gd_sender" name="gd_sender"   >
									</td>
									<td align="right"  nowrap class="td1">
										通知日期：
									</td>
									<td class="td2" nowrap >
										<input id="gd_notice_time" name="gd_notice_time" class="easyui-datebox" />
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										主要工作量及实施要求：
									</td>
									<td class="td2" nowrap colspan="3">
										<textarea id="gd_content" name="gd_content"   style="height:100%;width:100%" rows="6"></textarea>
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										细分专业：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="gd_detail_type_name" name="gd_detail_type_name"  />
									</td>
									<td align="right"  nowrap class="td1">
										总工时数：
									</td>
									<td class="td2" nowrap >
										<input id="gd_total_time" name="gd_total_time" class="easyui-numberbox" data-options="precision:3,required:true"/>
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										要求工期：
									</td>
									<td class="td2" nowrap >
										<input id="gd_start" name="gd_start" class="easyui-datebox" required="required"/>
									</td>
									<td align="right"  nowrap class="td1" style="text-align:center;font-size: 20px;font-weight: bold;">
										至
									</td>
									<td class="td2" nowrap >
										<input id="gd_will_end" name="gd_will_end" class="easyui-datebox" required="required"/>
									</td>
									
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										预警时间：
									</td>
									<td class="td2" nowrap >
										<input id="alarm_time" name="alarm_time" class="easyui-datebox" required="required"/>
									</td>
									<td align="right"  nowrap class="td1">
										材料管控精度：
									</td>
									<td class="td2" nowrap >
										<input id="control" name="control"/> %
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										其他预算金额：
									</td>
									<td class="td2" nowrap colspan="3" >
										<input id="other_assume_money" name="other_assume_money" class="easyui-numberbox" data-options="precision:2,required:true" /> 
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										管理公司：
									</td>
									<td class="td2" nowrap >
										<input id="company1" name="company1" />
									</td>
									<td align="right"  nowrap class="td1">
										实施公司：
									</td>
									<td class="td2" nowrap >
										<input id="company2" name="company2" />
									</td>
								</tr>
								<tr>
									<td align="right"  nowrap class="td1">
										收单单位：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="gd_worker_name" name="gd_worker_name"  >
									</td>
									<td align="right"  nowrap class="td1">
										实施负责人：
									</td>
									<td class="td2" nowrap >
										<input type="text" id="gd_worker_person" name="gd_worker_person"   >
									</td>
								</tr>
									<tr id="attaTr" style="display:none">
								      <td nowrap class="td1">附件明细: </td>
								      <td class="td2" colspan='3'>
								        <input type="hidden" id="attachmentId" name="attachmentId">
								        <input type="hidden" id="attachmentName" name="attachmentName">
								        <span id="showAtt">
								        </span>
								      </td>
							   	    </tr>
								<tr style="display:none;">
							      <td nowrap class="td1">附件：</td>
							      <td class="td2" colspan='3'>
							        	 <div id="fsUploadArea" class="flash" style="width:380px;">
										     <div id="fsUploadProgress"></div>
										     <div>
										       <input type="button" id="btnStart" class="SmallButtonW" value="开始上传" onclick="swfupload.startUpload();" disabled="disabled">&nbsp;&nbsp;
										       <input type="button" id="btnCancel" class="SmallButtonW" value="全部取消" onclick="javascript:swfupload.cancelQueue();jQuery('#fsUploadArea').hide();" disabled="disabled">&nbsp;&nbsp;
										    </div>
									      </div>
									      
										    <div id="attachment1">
									          <span id="spanButtonUpload" title="上传附件"></span>
									        </div>
							      </td>
					   		   </tr>
								<tr >
							      <td nowrap class="td1">打印：</td>
							      <td class="td2" colspan='3'>
							      		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:false" onclick="gdPrint();">打印工单预览</a>
							      </td>
					   		   </tr>
				 			</table>
				 			</form>
						</div>
						<div id="step-2" style="width:700px;height:550px">
							<div id="fb_detail" ></div>
						</div>
						<div id="step-3" style="width:700px;height:550px">
							<div id="material" ></div>
						</div>
					</div>
					<!-- End SmartWizard Content -->
				</td>
			</tr>
		</table>
		</div>
	</body>
</html>


